#include "place.h"

#include <QPainter>
#include <QGraphicsSceneDragDropEvent>
#include <QMimeData>
#include <QDebug>

const int RADIUS = 12;

Place::Place(int row, int col) :
    _color(Qt::transparent),
    _col(col),
    _row(row)
{
    setPos((col + 1) * RADIUS * 3, (row + 1) * RADIUS * 3);
    setZValue(-1);
    setAcceptDrops(true);
}

QRectF Place::boundingRect() const
{
    return QRectF(-RADIUS, -RADIUS, 2 * RADIUS, 2 * RADIUS);
}

void Place::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->setBrush(_color);
    painter->drawEllipse(-RADIUS, -RADIUS, 2 * RADIUS, 2 * RADIUS);
}

void Place::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
    qDebug() << event->mimeData()->formats ();
    event->setAccepted(event->mimeData()->hasFormat("text/plain"));
}
